﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Grishko.DataTier;
using OutdoorLib.BaseEntity.Agency;

public partial class DiscountList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
                    
        if (this.Page.Request["__EVENTTARGET"] == "RowGrid")
        {            
                OnRowClick(this.Page.Request["__EVENTARGUMENT"]);
        }      

        if (!IsPostBack)
        {         
            lvDiscountList.DataSource = Source;
            DataBind();
        }
    }

     
    protected List<Discount> Source { get{return AppEnvironment.CurrentAgency.Discounts.ToList<Discount>();}}
    protected void lvDiscountList_SelectedIndexChanged(object sender, EventArgs e)
    {
        
        

    }
    protected void btnAddRecord_Click(object sender, EventArgs e)
    {
        string sUrl = AppEnvironment.PageNavigator.GetNewObjectUrlCommand("PageKey_DiscountEditor",
                                                                       "Discount",
                                                                       null);
        Response.Redirect(sUrl);

    }

    protected string GetRowClick(string RowID)
    {
        string[] s = { "RowGrid", RowID };
        string ss= string.Format("CallServer('{0}', '{1}');", s);
        return ss;
    }
    protected void OnRowClick(string RowId)
    {
        string sUrl = AppEnvironment.PageNavigator.GetEditObjectUrlCommand("PageKey_DiscountEditor",
                                                                            RowId,
                                                                            "Discount",
                                                                             null);
        Response.Redirect(sUrl);

    }
}
